<?php

$uri = str_replace( _BASE_PATH, '', $_SERVER['REQUEST_URI'] );

$pageArray = explode( '/', $uri );

// original didnt work
//$thisPage = $pageArray[1];

// get the last elment of the uri ...
$thisPage = $pageArray[sizeof($pageArray)-1];

// no reference to a page? ... go to home page
if( $thisPage == '' )
{
	$thisPage = 'home';
}

// Ensure that only valid files can be included and use 404 if the
// requested page does not exist.
//print_r($thisPage);
if( !file_exists( 'views/'. $thisPage .'.php' ) )
{
	$thisPage = '404';
}

/*
 * Add controller(s) here.
*
* eg. include '/templates/tmp1.php'
*/

// Default template.
include _DOC_ROOT .'/templates/template_1.php';